package com.xxx.modules.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xxx.modules.mapper.CollegeMapper;
import com.xxx.modules.entity.College;
import com.xxx.modules.service.CollegeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Arrays;
import com.xxx.modules.utils.TimeUtil;

/**
 * college
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2023-04-29
 */
@Service
public class CollegeServiceImpl extends ServiceImpl<CollegeMapper, College> implements CollegeService {

    @Autowired
    private CollegeMapper collegeMapper;


    @Override
    public PageInfo<College> selectCollegeInfo(College college, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<College> wrapper = new QueryWrapper<>();
        if (college.getCollegeName() !=null){
            wrapper.like("college_name",college.getCollegeName());
        }
        if (college.getType() !=null){
            wrapper.eq("type",college.getType());
        }
        List<College> data = collegeMapper.selectList(wrapper);
        return new PageInfo<>(data);
    }

    @Override
    public void saveCollegeInfo(College college) {
        collegeMapper.insert(college);
    }

    @Override
    public void updateCollegeInfo(College college) {
        collegeMapper.updateById(college);
    }

    @Override
    public void delCollegeInfo(Integer id) {
        collegeMapper.deleteById(id);
    }

    @Override
    public void delBatchCollegeInfo(String idList) {
        List<String> list = Arrays.asList(idList.split(","));
        collegeMapper.deleteBatchIds(list);
    }


}